//
//  DLAppleLoginManager.h
//  AFNetworking
//
//  Created by dgg_hzk on 2020/4/15.
//

#import <Foundation/Foundation.h>

typedef NS_ENUM(NSUInteger, DLAppleLoginType) {
    DLAppleLoginTypeIDCredential = 0,
    DLAppleLoginTypePasswordCredential
};

@protocol DLAppleLoginDelegate <NSObject>

/**
 * 代理回调
 @param success 是否成功
 @param type 授权类型（钥匙串/AppleID）
 @param result 结果信息
 @param error 错误信息
*/
- (void)dl_AppleLogin:(BOOL)success loginType:(DLAppleLoginType)type result:(NSDictionary *)result error:(NSError *)error;

@end

@interface DLAppleLoginManager : NSObject

/// 代理回调
@property (nonatomic, weak) id<DLAppleLoginDelegate> delegate;

/**
 * 单例
 */
+ (instancetype)sharedInstance;

/**
 * 是否支持AppleID授权
*/
+ (BOOL)isSupportAppleIDAuth;

/**
 * 拉起授权
 @param window 用于展示在那个Window上
*/
- (void)loginAppleIdWithTargetWindow:(UIWindow *)window;

/**
 * 拉起授权
 @param window 用于展示在那个Window上
 @param resultBlock 授权回调
*/
- (void)loginAppleIdWithTargetWindow:(UIWindow *)window resultBlock:(void(^)(BOOL success, DLAppleLoginType type, NSDictionary *result, NSError *error))resultBlock;

@end
